package org.suwenqian.airoleplayingchatbackend.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.suwenqian.airoleplayingchatbackend.dao.dto.req.ChatReqDTO;
import org.suwenqian.airoleplayingchatbackend.service.ChatService;
import reactor.core.publisher.Flux;

@RestController
@RequiredArgsConstructor
@RequestMapping("/ai-role-play/chat")
public class ChatController {

    private final ChatService chatService;


    /**
     * AI 文本聊天接口
     * @param requestParm 请求参数
     * @return 响应信息
     */
    @PostMapping(value = "/streamMessage", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> streamMessage(@RequestBody ChatReqDTO requestParm) {
        return chatService.streamMessage(requestParm);
    }

}
